import React, { PureComponent } from 'react';
import { connect } from 'dva';
import Authorized from '@/utils/Authorized';
import { message, Row, Col, Table, Modal, Divider, InputNumber, Slider, Button, Input, Popconfirm, Empty, Tag } from 'antd';

@connect(({ competition }) => ({
  teacherGrade:competition.teacherGrade
}))
class TeacherScore extends PureComponent {
  state = {
    display: false,
    teacherGrade: [],
  }

  componentDidMount() {
    const { dispatch, userId, questionId, competitionId } = this.props;
    if (userId && questionId) {
      dispatch({
        type: 'competition/getTeacherGrade',
        payload: {
          'userId': userId,
          'questionId': questionId,
          'competitionId': competitionId,
        },
        callback:(res)=>{
          this.setState({
            teacherGrade:res,
          })
        }
      })
    }
  }

  render() {
    const { display, teacherGrade } = this.state;
    console.log(teacherGrade)
    const columns = [{
      title: '评委账号名',
      dataIndex: 'teacherUsername',
      key: 'username',
      render: text => <a href="javascript:;">{text}</a>,
    }, {
      title: '姓名',
      dataIndex: 'teacherName',
      key: 'name',
    }, {
      title: '分数',
      dataIndex: 'teacherScore',
      key: 'score',
      sorter: (a, b) => a.teacherScore - b.teacherScore,
    },{
      title: '操作',
      key: 'action',
      render: (text, record) => (
        <span>
          {/* <a onClick={() => this.handleClick(record.id)}>查看{record.name}提交的作品</a> */}
          <Divider type="vertical" />
          {/* <a onClick={() => this.handleCheck(record.id)}>查看评委评分详情</a> */}
        </span>
      ),
    }];
    return (
      <Authorized authority="admin">
        <Row>
          <Divider />
          <Col span={24}>
            <Table columns={columns} dataSource={teacherGrade} rowKey={record => record.id} />
          </Col>
        </Row>
      </Authorized>
    )
  }
}
export default TeacherScore;